package ar.com.e2solver.solver.operator.localsearch.mt;

import java.util.List;

import ar.com.e2solver.exception.BusinessException;
import ar.com.e2solver.solver.Individual;

public abstract class ClimbWorker implements Runnable {

	private Individual individual;
	private List<Individual> resultList;
	private int internalNumber;
	
	public ClimbWorker(Individual individual, List<Individual> resultList, int internalNumber){
		this.individual = individual;
		this.resultList = resultList;
		this.internalNumber = internalNumber;
	}
	
	public void run() {
		try {
			List<Individual> result = climb(this.individual);
			this.resultList.addAll(result);
		} catch (BusinessException e) {
			System.out.println("ClimbWorkerError " + this.getClass().getSimpleName() + " " + internalNumber);
			e.printStackTrace();
		}
	}
	
	protected abstract List<Individual> climb(Individual individual) throws BusinessException;
	
	protected Individual getIndividual(){
		return this.individual;
	}
	
	protected List<Individual> getResultList(){
		return this.resultList;
	}
	
	protected int getInternalNumber(){
		return this.internalNumber;
	}
}
